package gui.utils;

import java.awt.*;
import javax.swing.*;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class SliderWrap extends JPanel{
    private Slider sld;
    private JLabel lab;
    private JTextField val;

  
    public SliderWrap(int which, int maxVal, int minVal, int initialVal, String lab, int width, int txtCols){
        super(new BorderLayout());
        this.setOpaque(false);
        this.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
        if(!lab.equals("")){
            this.lab = new JLabel(lab);
            this.lab.setFont(Borders.getFont(Borders.GUIFONT));
            this.lab.setBorder(BorderFactory.createEmptyBorder(0,0,0,8));
            this.add(this.lab, BorderLayout.WEST);
        }
        sld = new Slider(which, maxVal, minVal, initialVal, width, this);
        this.add(sld, BorderLayout.CENTER);
        val = new JTextField(initialVal+"", txtCols);
        val.setOpaque(false);
        val.setBorder(null);
        val.setFont(Borders.getFont(Borders.GUIFONT));
        val.setEditable(false);
        this.add(val, BorderLayout.EAST);
    }

    public void setLabel(int val){
        if(val>=0){this.val.setText(val+"");}
        else{this.val.setText(val+"");}
    }

    public void setLabelSPSC(int val){
        if(val>=0){this.val.setText(val+"");}
        else{this.val.setText(val+"");}
        this.sld.slider.setValue(val);
    }
    
}